/*
 *  $Id: TormentRobe.cs 1220 2010-11-30 16:25:44Z thenn.erannor $
 *  This file is a part of Ragima CCG.
 *  (C) 2008-2009 Ragima development group.
 *
 *  Licensed under the terms of the GNU GPL License version 2.
 *
 */

namespace Ragima.Cards001.Light.Spells {
    public class TormentRobe : SelfEnchantmentCard {
        public TormentRobe() : base("001_l_s_torment_robe") {
            Level = CompleteLevel.ReadyForTest;
            Version = 0;
            Element = ElementType.Light;
            Value = 100;
            AddManaCost(1);
        }

        protected override EnchantmentAffect CreateEnchantment() {
            return new TormentRobeAffect();
        }

        private class TormentRobeAffect : EnchantmentAffect<TormentRobe> {
            public TormentRobeAffect() {
                Add(new Affects.AbilityAffect(new TormentRobeAbility()));
            }
        }

        private class TormentRobeAbility : AbilityCard<HandCardData> {
            public TormentRobeAbility() : base("001_l_a_torment_robe") {
                Level = CompleteLevel.ReadyForTest;
                SetPictureSource<TormentRobe>();
                Version = 0;
                Element = ElementType.Light;
                Target = new HandCardTarget(GetTargetPhrase(), IsLightOpened);
            }

            private static bool IsLightOpened(TargetRequest request, HandCard card) {
                return card.Opened && card.Card.ManaCost[ElementType.Light] > request.Player.GetMana(ElementType.Light);
            }

            protected override void ManaCostAction(TargetArgs<HandCardData> args, ElementValues manas) {
                int mana = args.Target.Card.Card.ManaCost[ElementType.Light] - args.Player.GetMana(ElementType.Light);
                manas.Increment(ElementType.Health, mana);
            }

            protected override void DoAction(TargetArgs<HandCardData> args) {
                int mana = args.Target.Card.Card.ManaCost[ElementType.Light] - args.Player.GetMana(ElementType.Light);
                args.Player.IncrementMana(ElementType.Light, mana);
            }
        }
    }
}
